package com.analyse.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.analyse.common.annotation.Log;
import com.analyse.common.core.controller.BaseController;
import com.analyse.common.core.domain.AjaxResult;
import com.analyse.common.enums.BusinessType;
import com.analyse.system.domain.Weibv3Topic;
import com.analyse.system.service.IWeibv3TopicService;
import com.analyse.common.utils.poi.ExcelUtil;
import com.analyse.common.core.page.TableDataInfo;

/**
 * 关键词检索Controller
 * 
 * @author analyse
 * @date 2023-05-09
 */
@RestController
@RequestMapping("/system/topic")
public class Weibv3TopicController extends BaseController
{
    @Autowired
    private IWeibv3TopicService weibv3TopicService;

    /**
     * 查询关键词检索列表
     */
    @PreAuthorize("@ss.hasPermi('system:topic:list')")
    @GetMapping("/list")
    public TableDataInfo list(Weibv3Topic weibv3Topic)
    {
        startPage();
        List<Weibv3Topic> list = weibv3TopicService.selectWeibv3TopicList(weibv3Topic);
        return getDataTable(list);
    }

    /**
     * 导出关键词检索列表
     */
    @PreAuthorize("@ss.hasPermi('system:topic:export')")
    @Log(title = "关键词检索", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Weibv3Topic weibv3Topic)
    {
        List<Weibv3Topic> list = weibv3TopicService.selectWeibv3TopicList(weibv3Topic);
        ExcelUtil<Weibv3Topic> util = new ExcelUtil<Weibv3Topic>(Weibv3Topic.class);
        util.exportExcel(response, list, "关键词检索数据");
    }

    /**
     * 获取关键词检索详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:topic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(weibv3TopicService.selectWeibv3TopicById(id));
    }

    /**
     * 新增关键词检索
     */
    @PreAuthorize("@ss.hasPermi('system:topic:add')")
    @Log(title = "关键词检索", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Weibv3Topic weibv3Topic)
    {
        return toAjax(weibv3TopicService.insertWeibv3Topic(weibv3Topic));
    }

    /**
     * 修改关键词检索
     */
    @PreAuthorize("@ss.hasPermi('system:topic:edit')")
    @Log(title = "关键词检索", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Weibv3Topic weibv3Topic)
    {
        return toAjax(weibv3TopicService.updateWeibv3Topic(weibv3Topic));
    }

    /**
     * 删除关键词检索
     */
    @PreAuthorize("@ss.hasPermi('system:topic:remove')")
    @Log(title = "关键词检索", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(weibv3TopicService.deleteWeibv3TopicByIds(ids));
    }
}
